package com.yk.spark.controller.manage;

import com.yk.spark.service.manage.app.api.IAppManageService;
import org.json.JSONArray;
import org.json.JSONException;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;

/**
 * Created by Limit on 2017/8/23.
 */
@Controller
@RequestMapping("/manage")
public class ManageController {

    @Resource(name = "appManageService")
    private IAppManageService appManageService;

//    @RequestMapping("startApp")
//    @ResponseBody
//    public Object startApp(@RequestParam String appId,@RequestParam String input,@RequestParam String output) throws JSONException {
//        return this.appManageService.startApp(appId,new JSONArray(input),output);
//    }

    @RequestMapping("startApp")
    @ResponseBody
    public Object startApp(@RequestParam String appId) throws JSONException {
        return this.appManageService.startApp(appId);
    }

    @RequestMapping("stopApp")
    @ResponseBody
    public Object stopApp(@RequestParam String appId) throws Exception {

        return this.appManageService.stopApp(appId);
    }

    @RequestMapping("getAppStatus")
    @ResponseBody
    public Object getAppSubmitStatus(@RequestParam String appId) throws Exception {
        return this.appManageService.queryProcessState(appId);
    }

}
